package com.ruoyi.compensationManagement.service.impl;

import java.math.BigDecimal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.compensationManagement.mapper.CompensationDeductionAmountSettingsMapper;
import com.ruoyi.compensationManagement.domain.CompensationDeductionAmountSettings;
import com.ruoyi.compensationManagement.service.ICompensationDeductionAmountSettingsService;

/**
 * 扣款金额设置Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-10-05
 */
@Service
public class CompensationDeductionAmountSettingsServiceImpl implements ICompensationDeductionAmountSettingsService 
{
    @Autowired
    private CompensationDeductionAmountSettingsMapper compensationDeductionAmountSettingsMapper;

    /**
     * 查询扣款金额设置
     * 
     * @param id 扣款金额设置主键
     * @return 扣款金额设置
     */
    @Override
    public CompensationDeductionAmountSettings selectCompensationDeductionAmountSettingsById(Long id)
    {
        return compensationDeductionAmountSettingsMapper.selectCompensationDeductionAmountSettingsById(id);
    }

    /**
     * 查询扣款金额设置列表
     * 
     * @param compensationDeductionAmountSettings 扣款金额设置
     * @return 扣款金额设置
     */
    @Override
    public List<CompensationDeductionAmountSettings> selectCompensationDeductionAmountSettingsList(CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        return compensationDeductionAmountSettingsMapper.selectCompensationDeductionAmountSettingsList(compensationDeductionAmountSettings);
    }

    /**
     * 新增扣款金额设置
     * 
     * @param compensationDeductionAmountSettings 扣款金额设置
     * @return 结果
     */
    @Override
    public int insertCompensationDeductionAmountSettings(CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        return compensationDeductionAmountSettingsMapper.insertCompensationDeductionAmountSettings(compensationDeductionAmountSettings);
    }

    /**
     * 修改扣款金额设置
     * 
     * @param compensationDeductionAmountSettings 扣款金额设置
     * @return 结果
     */
    @Override
    public int updateCompensationDeductionAmountSettings(CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        if("Y".equals(compensationDeductionAmountSettings.getIsRate())){
            compensationDeductionAmountSettings.setCost(new BigDecimal(0));
        }else{
            compensationDeductionAmountSettings.setRate(new BigDecimal(0));
        }
        return compensationDeductionAmountSettingsMapper.updateCompensationDeductionAmountSettings(compensationDeductionAmountSettings);
    }

    /**
     * 批量删除扣款金额设置
     * 
     * @param ids 需要删除的扣款金额设置主键
     * @return 结果
     */
    @Override
    public int deleteCompensationDeductionAmountSettingsByIds(Long[] ids)
    {
        return compensationDeductionAmountSettingsMapper.deleteCompensationDeductionAmountSettingsByIds(ids);
    }

    /**
     * 删除扣款金额设置信息
     * 
     * @param id 扣款金额设置主键
     * @return 结果
     */
    @Override
    public int deleteCompensationDeductionAmountSettingsById(Long id)
    {
        return compensationDeductionAmountSettingsMapper.deleteCompensationDeductionAmountSettingsById(id);
    }
}
